Skip to content

Analyze cross-package orchestration helpers with orchestratorvet - #197

Open
andystaples wants to merge 3 commits into
mainfrom
andystaples-cross-package-orchestrator-vet
Open

andystaples wants to merge 3 commits into
mainfrom
andystaples-cross-package-orchestrator-vet

Conversation

@andystaples

Copy link
Copy Markdown
Contributor

orchestratorvet now follows statically resolved calls into other packages in the same Go module, including orchestrator handlers passed directly to a registry from an import. Go analysis facts carry replay-hazard summaries through imports. Diagnostics stay rooted in orchestrator registrations and show a representative call path at the local registration or call site; code used only by activities does not produce a diagnostic.

The analyzer does not follow dynamic dispatch or cross-module calls, offer fixes for imported code, or expand its registry-name or loop-progress checks.

Closes #178.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 19:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the changes extending replay-hazard detection across packages.

No open issues 🎉

What changed in this PR

Extends orchestratorvet to detect replay hazards in statically resolved orchestrators and helpers across packages within the same Go module, addressing #178 while keeping diagnostics rooted in orchestrator registrations.

Changes:

  • Adds analysis facts that propagate hazard summaries and representative call paths across imports.
  • Supports imported handlers and concrete methods while preserving conservative behavior for unresolved calls.
  • Adds cross-package integration coverage, updates benchmarks, and documents the expanded scope and limitations.
File Description
cmd/​orchestratorvet/​README.md Documents cross-package analysis and its limits.
cmd/​orchestratorvet/​analysis/​orchestratorgo/​registration.go Records imported orchestrator registration roots.
cmd/​orchestratorvet/​analysis/​orchestratorgo/​reach.go Enumerates local and imported call targets.
cmd/​orchestratorvet/​analysis/​orchestratorgo/​index.go Resolves imported functions and handles ambiguous function values conservatively.
cmd/​orchestratorvet/​analysis/​orchestratorgo/​facts.go Builds and propagates same-module hazard summaries.
cmd/​orchestratorvet/​analysis/​orchestratorgo/​facts_test.go Tests cross-package diagnostics and excluded call paths.
cmd/​orchestratorvet/​analysis/​orchestratorgo/​checks.go Adds hazard collection without local fixes or registry-dependent checks.
cmd/​orchestratorvet/​analysis/​orchestratorgo/​bench_test.go Updates benchmarks to exercise summary construction.
cmd/​orchestratorvet/​analysis/​orchestratorgo/​analyzer.go Integrates fact export and imported-hazard reporting.

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 19:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The cross-package replay-hazard analysis changes have no active review issues.

No open issues 🎉

Review effort: Balanced

Importer reassignment of exported package variables only matters for
cross-package summaries. Restrict that exclusion to fact construction so
same-package registrations and calls through exported variables are
still analyzed as before.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 00:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the cross-package replay-hazard analysis changes.

No open issues 🎉

Review effort: Balanced

@berndverst Bernd Verst (berndverst) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact-based approach works for direct imports and transitive helpers, including when vet only targets the registration package. I would fix the false positive below before merging: a seed set to a constant before orchestration still causes go vet to fail. The range-over-function case is separate and non-blocking; please either follow statically known iterators or document the limit.

if node.Op == token.AND {
if id, ok := ast.Unparen(node.X).(*ast.Ident); ok {
if variable, ok := pass.TypesInfo.ObjectOf(id).(*types.Var); ok {
if mayHoldFunction(variable.Type()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The address-taken check only invalidates function values, but exported facts also use singleValue to prove a random seed. A helper can expose the seed through a pointer:

var seed = time.Now().UnixNano()
var Seed = &seed

func Roll() int {
    r := rand.New(rand.NewSource(seed))
    return r.Int()
}

If the registration package sets *helper.Seed = 123 in init, each orchestration call to helper.Roll() creates a fresh RNG with the same seed. I reproduced a nondeterministic-seed diagnostic and a failing go vet on this revision. Can we treat address-taken seed values as unknown when exporting summaries and cover this in the integration fixture?

}

func (index *packageIndex) forEachTarget(node ast.Node, visit func(token.Pos, functionTarget)) {
forEachOwnedCall(node, func(call *ast.CallExpr) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: forEachOwnedCall only sees explicit calls. A registered orchestrator using for range helper.Iter {} still invokes that statically known iterator, but vet misses a time.Now() inside it. Calling the same helper explicitly with helper.Iter(func(int) bool { return true }) is covered. Could we follow statically resolved iterators in range expressions, or document this limitation in the README?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analyze cross-package orchestration helpers with orchestratorvet

3 participants